/* 全局样式和CSS变量 */
:root {
    /* 主题颜色 */
    --primary-color: #00a4ff;
    --primary-color-dark: #0084cc; /* 添加深色版本 */
    --secondary-color: #ff7c2d;
    --text-color: #333;
    --text-light: #666;
    --text-lighter: #999;
    --bg-color: #f3f5f7;
    --white: #fff;
    
    /* 间距 */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 30px;
    
    /* 阴影 */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
    
    /* 尺寸 */
    --container-width: 1200px;
    --header-height: 100px;
    --banner-height: 420px;
    --sidebar-width: 190px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
    font-family: "Microsoft YaHei", sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
}

a {
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.3s ease;
}

ul, li {
    list-style: none;
}

.wrapper {
    width: var(--container-width);
    margin: 0 auto;
}

/* 头部区域 */
.header {
    background-color: var(--white);
    height: var(--header-height);
    box-shadow: var(--shadow-sm);
}

.header .wrapper {
    display: flex;
    align-items: center;
    height: 100%;
}

.logo {
    margin-right: 70px;
}

.logo img {
    width: 150px;
    height: auto;
}

/* 导航菜单 */
.nav ul {
    display: flex;
}

.nav li {
    margin-right: 25px;
}

.nav a {
    font-size: 16px;
    padding: 0 8px;
    line-height: var(--header-height);
    position: relative;
    transition: color 0.3s ease;
}

.nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
}

.nav a.active, .nav a:hover {
    color: var(--primary-color);
}

.nav a.active::after, .nav a:hover::after {
    width: 100%;
    left: 0;
}

/* 搜索框 */
.search {
    margin-left: auto;
    display: flex;
}

.search input {
    width: 360px;
    height: 40px;
    padding: 0 15px;
    border: 1px solid var(--primary-color);
    border-right: none;
    font-size: 14px;
    color: #bfbfbf;
    border-radius: 20px 0 0 20px;
    outline: none;
}

.search button {
    width: 50px;
    height: 40px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
}

/* 用户信息 */
.user-info {
    margin-left: 30px;
    display: flex;
    align-items: center;
}

.user-info img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
}

/* 轮播图区域 */
.banner {
    height: var(--banner-height);
    background-color: #1c036c;
    position: relative;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    overflow: hidden;
}

.banner .wrapper {
    position: relative;
    height: 100%;
    width: var(--container-width);
    margin: 0 auto;
}

/* 轮播图组件 */
.carousel {
    width: 100vw;
    height: 100%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden;
}

.slides {
    width: 100vw;
    height: 100%;
    position: relative;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: opacity; /* 优化动画性能 */
}

.slide.active {
    opacity: 1;
    z-index: 2;
}

.slide img {
    width: 100vw;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* 轮播指示器 */
.carousel-btns {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    z-index: 10;
}

.carousel-btns span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    margin: 0 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.carousel-btns span.active {
    background-color: var(--primary-color);
}

.carousel-btns span:hover {
    background-color: rgba(255, 255, 255, 0.8);
}

/* 左侧导航栏 */
.sidebar {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 10px 0;
    z-index: 5;
}

.sidebar ul {
    padding: 5px 0;
}

.sidebar li {
    height: 40px;
    line-height: 40px;
    padding: 0 20px;
    position: relative;
}

.sidebar li a {
    color: var(--white);
    font-size: 14px;
    display: block;
}

.sidebar li:hover {
    background-color: var(--primary-color);
}

/* 子菜单样式 */
.sub-menu {
    display: none;
    position: absolute;
    top: 0;
    left: var(--sidebar-width);
    width: 700px;
    height: var(--banner-height);
    background-color: var(--white);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-lg);
    z-index: 999;
}

.sidebar li:hover .sub-menu {
    display: block;
}

.sub-menu dl {
    float: left;
    width: 20%;
    margin-bottom: var(--spacing-lg);
}

.sub-menu dt {
    color: var(--primary-color);
    font-size: 16px;
    font-weight: bold;
    margin-bottom: var(--spacing-sm);
}

.sub-menu dd {
    height: 30px;
    line-height: 30px;
}

.sub-menu dd a {
    color: var(--text-light);
    font-size: 14px;
}

.sub-menu dd a:hover {
    color: var(--primary-color);
}

/* 右侧课程表 */
.course-list {
    position: absolute;
    right: 0;
    top: 50px;
    width: 230px;
    height: 300px;
    background-color: var(--white);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-lg);
    z-index: 5;
}

.course-list h3 {
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 15px;
}

.course-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f1f1;
}

.course-item img {
    width: 50px;
    height: 50px;
    margin-right: 10px;
}

.course-item p {
    font-size: 14px;
    line-height: 1.5;
}

#continue-learning {
    display: block;
    width: 100%;
    height: 40px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    margin-top: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#continue-learning:hover {
    background-color: var(--primary-color-dark);
    opacity: 0.9;
}

/* 内容区域 */
.content {
    padding: var(--spacing-lg) 0;
    background-color: var(--bg-color);
}

/* 我的兴趣 */
.interest {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    background-color: var(--white);
    box-shadow: var(--shadow-sm);
    margin-bottom: 15px;
    padding: 0 30px;
}

.interest ul {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto; /* 允许横向滚动以适应更多内容 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.interest ul::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

.interest li {
    margin: 0 15px;
    font-size: 16px;
    color: var(--text-light);
    white-space: nowrap;
}

/* 兴趣标签点击效果 */
.interest li:not(:nth-child(even)) {
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.interest li:not(:nth-child(even)):hover {
    background-color: rgba(0, 164, 255, 0.1);
}

.interest li.active {
    color: var(--primary-color);
    background-color: rgba(0, 164, 255, 0.1);
}

.modify {
    color: var(--primary-color);
    font-size: 14px;
    white-space: nowrap;
    margin-left: var(--spacing-md);
}

/* 课程模块通用样式 */
.section-header {
    display: flex;
    align-items: center;
    height: 60px;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 20px;
    color: #494949;
    font-weight: normal;
    margin-right: auto;
}

/* 分类标签切换效果 */
.tab {
    margin-left: 30px;
    display: flex;
    flex-wrap: wrap;
}

.tab a {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 15px;
    transition: all 0.3s ease;
    margin: 0 5px 5px;
}

.tab a:hover {
    color: var(--primary-color);
    background-color: rgba(0, 164, 255, 0.1);
}

.tab a.active {
    color: var(--white);
    background-color: var(--primary-color);
}

.section-header .more {
    margin-left: var(--spacing-lg);
    color: var(--text-lighter);
    font-size: 14px;
}

/* 共用的模块样式 */
.recommend, .programming, .data-analysis, .machine-learning, .frontend-development {
    background-color: var(--white);
    box-shadow: var(--shadow-sm);
    margin-bottom: 15px;
    padding: var(--spacing-lg);
}

/* 课程盒子样式 */
.course-container {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.course-box {
    width: 20%;
    padding: 0 10px;
    margin-bottom: var(--spacing-lg);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.course-box img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 4px;
}

.course-box h4 {
    font-size: 14px;
    color: var(--text-color);
    margin: 10px 0;
    text-align: center;
    font-weight: normal;
    /* 多行文本截断 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 38px;
}

.course-box p {
    font-size: 12px;
    color: var(--text-lighter);
    text-align: center;
    white-space: nowrap;
}

.level {
    color: var(--secondary-color);
}

/* 特定模块布局 */
.course-layout {
    display: flex;
    gap: var(--spacing-md);
}

.left-banner {
    width: 228px;
    height: 392px;
    flex-shrink: 0;
}

.left-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.right-content {
    flex: 1;
    min-width: 0; /* 防止flex子项溢出 */
}

.top-banner {
    width: 100%;
    height: 100px;
    margin-bottom: 15px;
}

.top-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.course-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

/* 页脚区域 */
.footer {
    background-color: var(--white);
    padding: 30px 0;
    margin-top: 30px;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.footer .wrapper {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

.footer-left {
    width: 440px;
}

.footer-left img {
    width: 150px;
    height: auto;
    margin-bottom: var(--spacing-lg);
}

.footer-left p {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.8;
}

.footer-right {
    display: flex;
    flex-wrap: wrap;
}

.footer-right dl {
    margin: 0 50px;
    min-width: 120px;
}

.footer-right dt {
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 15px;
    font-weight: bold;
}

.footer-right dd {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.footer-right dd a:hover {
    color: var(--primary-color);
}

/* 固定左侧导航栏 */
.fixed-sidebar {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 15px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.fixed-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fixed-sidebar li {
    margin: 10px 0;
}

.fixed-sidebar a {
    display: block;
    color: var(--text-light);
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
}

.fixed-sidebar a:hover {
    color: var(--primary-color);
    background: rgba(0, 164, 255, 0.1);
}

.fixed-sidebar a.active {
    color: var(--white);
    background: var(--primary-color);
}

/* 响应式媒体查询优化 */
@media screen and (max-width: 1300px) {
    .fixed-sidebar {
        left: 10px;
        padding: 10px;
    }
    
    .fixed-sidebar a {
        padding: 5px 10px;
        font-size: 12px;
    }
}

@media screen and (max-width: 1200px) {
    :root {
        --container-width: 100%;
    }
    
    .wrapper {
        padding: 0 15px;
    }
    
    .course-box, .course-row .course-box {
        width: 25%;
    }
}

@media screen and (max-width: 992px) {
    .sidebar, .course-list, .left-banner {
        display: none;
    }
    
    .course-box, .course-row .course-box {
        width: 33.333%;
    }
}

@media screen and (max-width: 768px) {
    :root {
        --banner-height: 250px;
    }
    
    .nav, .fixed-sidebar {
        display: none;
    }
    
    .search {
        margin-left: 20px;
    }
    
    .search input {
        width: 200px;
    }
    
    .course-box, .course-row .course-box {
        width: 50%;
    }
    
    .footer .wrapper {
        flex-direction: column;
    }
    
    .footer-left {
        width: 100%;
        margin-bottom: 30px;
    }
    
    .carousel-btns {
        bottom: 10px;
    }
    
    .carousel-btns span {
        width: 8px;
        height: 8px;
        margin: 0 3px;
    }
}

@media screen and (max-width: 576px) {
    .course-box, .course-row .course-box {
        width: 100%;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding: 10px 0;
    }
    
    .tab {
        margin: 10px 0;
    }
    
    .section-header .more {
        margin: 10px 0 0;
        align-self: flex-end;
    }
}
